<?php
// +-------------------------------------------------------------------
// |
// +-------------------------------------------------------------------
// | Copyright (c) 2009-2016 All rights reserved.
// +-------------------------------------------------------------------
namespace Service\Api\V1;

use Think\Exception;

class UserServiceOrderDetail
{
    public $login = true; //是否需要登录才能访问该接口
    public $title = "预约详情ok";
    public $group = '物业服务';
    public $desc = "";

    public $input = [
        'id' => 'int;required;label=预约id',
    ];

    public $output = [
        'id' => 'label=预约id;',
        'logo_img' => 'label=logo图;',
        'infor_title' => 'label=标题;',
        'type_name' => 'label=类型名称;',
        'create_time' => 'label=创建时间;',
        'contact' => 'label=联系人;',
        'mobile' => 'label=联系电话;',
        'content' => 'label=信息详情;',
        'address' => 'label=服务地址;',
        'remark' => 'label=备注;',
        'booking_time' => 'label=服务时间;',
        'state' => 'label=订单类型：0提交 1待确认 2待指派 3已指派 4已完成 9已取消;',
    ];

    public function run($param, $uid)
    {

        $list = M('service_order')
            ->where([
                'id' => $param['id'],
            ])
           ->find();
        if(!$list) throw new Exception('未找到记录');
        $ret = M('service')->where(['id' => $list['service_id']])->find();
        $list['logo_img'] = $ret['logo_img'];
        $list['create_time'] = $ret['create_time'];
        $list['infor_title'] = $ret['infor_title'];
        $list['content'] = $ret['content'];
        $list['logo_img'] = $ret['logo_img'];
//        $list['contact'] = $ret['contact'];
//        $list['mobile'] = $ret['mobile'];
        $type_data = M('service_type')->where(['id' => $ret['service_type_id']])->find();
        $list['type_name'] = $type_data['name'];
        return $list;

    }
}
